import React, { useState,useEffect } from 'react'
import { View, Text } from '@tarojs/components'
import { AtSearchBar } from 'taro-ui'
// import taro from '@tarojs/taro'
import ActiveContent from '../../compontents/activeContent'
import ToLogin from '../../compontents/toLogin'
import Taro, {  useShareAppMessage,useShareTimeline } from '@tarojs/taro'
import Navbar from '../../compontents/navbar'


import "taro-ui/dist/style/components/search-bar.scss";
import "taro-ui/dist/style/components/button.scss";
import "taro-ui/dist/style/components/icon.scss";


import './index.less'

export default (props: any) => {
  const [title,setTitle]=useState('')
  let t1 = ''
  const onChange = (e)=>{
    t1 = e
  }
  const onActionClick = ()=>{
    setTitle(t1)
  }
  useShareAppMessage(res => {
    if (res.from === 'button') {
      // 来自页面内转发按钮
      console.log(res.target)
    }
    return {
      title: 'U你校园活动',
      path: '/pages/active/index'
    }
  })
  useShareTimeline(()=>{
    return{
			title:'U你校园活动',
      path: '/pages/active/index',
			query:'' 	
		}
  })
  return (
    <View className='active'>
      <ToLogin url='/pages/active/index'></ToLogin>
      <AtSearchBar
        className='search'
        value={''}
        onChange={onChange}
        onActionClick={onActionClick}
      />
      <ActiveContent title={title}/>
      <Navbar></Navbar>
    </View>
  );
};
